import java.time.Duration;

public class TimeCaculation {
    public static long calculateTimeSpan(Phone p){
        long finaltime;
        Duration duration = Duration.between(p.startTime,p.endTime);
        if(p.startTime.getSecond()<p.endTime.getSecond())
            finaltime= duration.toMinutes()+1;
        else finaltime= duration.toMinutes();

        if(p.is_forward)
            finaltime-=60;
        if(p.is_back)
            finaltime+=60;
        if(finaltime<=0||finaltime>30*60){
            return -1;
        }
        else return finaltime;
    }
}
